﻿Imports System.Timers
Imports HslCommunication
Imports HslCommunication.Profinet.Siemens
Imports HslControls
Public Class ucRGV

    'Private _RGV_PLC As HslCommunication.Profinet.Siemens.SiemensS7Net
    'Private _connectSuccess As Boolean
    Private _StationNo As Integer
    Private _CarName As String
    Private _doorOpen As Boolean
    Private _stopCmd As Boolean = False
    Private _mapNo As Integer
    Private _Stop_0 As Boolean = False
    Private _Stop_1 As Boolean = False
    Private _ControlMode As Boolean = False
    Private _CarStop As Boolean = False

    Private _M_11挡板升 As Boolean = False
    Private _M_11挡板降 As Boolean = False
    Private _M_12挡板升 As Boolean = False
    Private _M_12挡板降 As Boolean = False
    Private _M_21挡板升 As Boolean = False
    Private _M_21挡板降 As Boolean = False
    Private _M_22挡板升 As Boolean = False
    Private _M_22挡板降 As Boolean = False
    Private _M_1滚轮正转 As Boolean = False
    Private _M_1滚轮反转 As Boolean = False
    Private _M_2滚轮正转 As Boolean = False
    Private _M_2滚轮反转 As Boolean = False
    Private _手动自动 As Integer = 0 '0自动，1手动

    Public _1下料完成 As Boolean
    Public _2下料完成 As Boolean
    Public _1上料完成 As Boolean
    Public _2上料完成 As Boolean


    'Private WithEvents timer1 As New System.Timers.Timer

    Public Property CarName As String
        Get
            Return _CarName
        End Get
        Set(value As String)
            _CarName = value
            lblCarName.Text = value
        End Set
    End Property

    Public Property StationNo As Integer
        Get
            Return _StationNo
        End Get
        Set(value As Integer)
            _StationNo = value
        End Set
    End Property

    Public Property DoorOpen As Boolean
        Get
            Return _doorOpen
        End Get
        Set(value As Boolean)
            _doorOpen = value
            lblDoor.Visible = value
        End Set
    End Property

    Public Property StopCmd As Boolean
        Get
            Return _stopCmd
        End Get
        Set(value As Boolean)
            _stopCmd = value
        End Set
    End Property

    Public Property MapNo As Integer
        Get
            Return _mapNo
        End Get
        Set(value As Integer)
            _mapNo = value
        End Set
    End Property

    Public Property Stop_0 As Boolean
        Get
            Return _Stop_0
        End Get
        Set(value As Boolean)
            _Stop_0 = value
        End Set
    End Property

    Public Property Stop_1 As Boolean
        Get
            Return _Stop_1
        End Get
        Set(value As Boolean)
            _Stop_1 = value
        End Set
    End Property

    Public Property M_11挡板升 As Boolean
        Get
            Return _M_11挡板升
        End Get
        Set(value As Boolean)
            _M_11挡板升 = False
            _M_11挡板降 = False
            _M_12挡板升 = False
            _M_12挡板降 = False
            _M_21挡板升 = False
            _M_21挡板降 = False
            _M_22挡板升 = False
            _M_22挡板降 = False
            _M_1滚轮正转 = False
            _M_1滚轮反转 = False
            _M_2滚轮正转 = False
            _M_2滚轮反转 = False

            _M_11挡板升 = value
        End Set
    End Property

    Public Property M_11挡板降 As Boolean
        Get
            Return _M_11挡板降
        End Get
        Set(value As Boolean)
            _M_11挡板升 = False
            _M_11挡板降 = False
            _M_12挡板升 = False
            _M_12挡板降 = False
            _M_21挡板升 = False
            _M_21挡板降 = False
            _M_22挡板升 = False
            _M_22挡板降 = False
            _M_1滚轮正转 = False
            _M_1滚轮反转 = False
            _M_2滚轮正转 = False
            _M_2滚轮反转 = False

            _M_11挡板降 = value
        End Set
    End Property

    Public Property M_12挡板升 As Boolean
        Get
            Return _M_12挡板升
        End Get
        Set(value As Boolean)
            _M_11挡板升 = False
            _M_11挡板降 = False
            _M_12挡板升 = False
            _M_12挡板降 = False
            _M_21挡板升 = False
            _M_21挡板降 = False
            _M_22挡板升 = False
            _M_22挡板降 = False
            _M_1滚轮正转 = False
            _M_1滚轮反转 = False
            _M_2滚轮正转 = False
            _M_2滚轮反转 = False

            _M_12挡板升 = value
        End Set
    End Property

    Public Property M_12挡板降 As Boolean
        Get
            Return _M_12挡板降
        End Get
        Set(value As Boolean)
            _M_11挡板升 = False
            _M_11挡板降 = False
            _M_12挡板升 = False
            _M_12挡板降 = False
            _M_21挡板升 = False
            _M_21挡板降 = False
            _M_22挡板升 = False
            _M_22挡板降 = False
            _M_1滚轮正转 = False
            _M_1滚轮反转 = False
            _M_2滚轮正转 = False
            _M_2滚轮反转 = False

            _M_12挡板降 = value
        End Set
    End Property

    Public Property M_21挡板升 As Boolean
        Get
            Return _M_21挡板升
        End Get
        Set(value As Boolean)
            _M_11挡板升 = False
            _M_11挡板降 = False
            _M_12挡板升 = False
            _M_12挡板降 = False
            _M_21挡板升 = False
            _M_21挡板降 = False
            _M_22挡板升 = False
            _M_22挡板降 = False
            _M_1滚轮正转 = False
            _M_1滚轮反转 = False
            _M_2滚轮正转 = False
            _M_2滚轮反转 = False

            _M_21挡板升 = value
        End Set
    End Property

    Public Property M_21挡板降 As Boolean
        Get
            Return _M_21挡板降
        End Get
        Set(value As Boolean)
            _M_11挡板升 = False
            _M_11挡板降 = False
            _M_12挡板升 = False
            _M_12挡板降 = False
            _M_21挡板升 = False
            _M_21挡板降 = False
            _M_22挡板升 = False
            _M_22挡板降 = False
            _M_1滚轮正转 = False
            _M_1滚轮反转 = False
            _M_2滚轮正转 = False
            _M_2滚轮反转 = False

            _M_21挡板降 = value
        End Set
    End Property

    Public Property M_22挡板升 As Boolean
        Get
            Return _M_22挡板升
        End Get
        Set(value As Boolean)
            _M_11挡板升 = False
            _M_11挡板降 = False
            _M_12挡板升 = False
            _M_12挡板降 = False
            _M_21挡板升 = False
            _M_21挡板降 = False
            _M_22挡板升 = False
            _M_22挡板降 = False
            _M_1滚轮正转 = False
            _M_1滚轮反转 = False
            _M_2滚轮正转 = False
            _M_2滚轮反转 = False

            _M_22挡板升 = value
        End Set
    End Property

    Public Property M_22挡板降 As Boolean
        Get
            Return _M_22挡板降
        End Get
        Set(value As Boolean)
            _M_11挡板升 = False
            _M_11挡板降 = False
            _M_12挡板升 = False
            _M_12挡板降 = False
            _M_21挡板升 = False
            _M_21挡板降 = False
            _M_22挡板升 = False
            _M_22挡板降 = False
            _M_1滚轮正转 = False
            _M_1滚轮反转 = False
            _M_2滚轮正转 = False
            _M_2滚轮反转 = False

            _M_22挡板降 = value
        End Set
    End Property

    Public Property M_1滚轮正转 As Boolean
        Get
            Return _M_1滚轮正转
        End Get
        Set(value As Boolean)
            _M_11挡板升 = False
            _M_11挡板降 = False
            _M_12挡板升 = False
            _M_12挡板降 = False
            _M_21挡板升 = False
            _M_21挡板降 = False
            _M_22挡板升 = False
            _M_22挡板降 = False
            _M_1滚轮正转 = False
            _M_1滚轮反转 = False
            _M_2滚轮正转 = False
            _M_2滚轮反转 = False

            _M_1滚轮正转 = value
        End Set
    End Property

    Public Property M_1滚轮反转 As Boolean
        Get
            Return _M_1滚轮反转
        End Get
        Set(value As Boolean)
            _M_11挡板升 = False
            _M_11挡板降 = False
            _M_12挡板升 = False
            _M_12挡板降 = False
            _M_21挡板升 = False
            _M_21挡板降 = False
            _M_22挡板升 = False
            _M_22挡板降 = False
            _M_1滚轮正转 = False
            _M_1滚轮反转 = False
            _M_2滚轮正转 = False
            _M_2滚轮反转 = False

            _M_1滚轮反转 = value
        End Set
    End Property

    Public Property M_2滚轮正转 As Boolean
        Get
            Return _M_2滚轮正转
        End Get
        Set(value As Boolean)
            _M_11挡板升 = False
            _M_11挡板降 = False
            _M_12挡板升 = False
            _M_12挡板降 = False
            _M_21挡板升 = False
            _M_21挡板降 = False
            _M_22挡板升 = False
            _M_22挡板降 = False
            _M_1滚轮正转 = False
            _M_1滚轮反转 = False
            _M_2滚轮正转 = False
            _M_2滚轮反转 = False

            _M_2滚轮正转 = value
        End Set
    End Property

    Public Property M_2滚轮反转 As Boolean
        Get
            Return _M_2滚轮反转
        End Get
        Set(value As Boolean)
            _M_11挡板升 = False
            _M_11挡板降 = False
            _M_12挡板升 = False
            _M_12挡板降 = False
            _M_21挡板升 = False
            _M_21挡板降 = False
            _M_22挡板升 = False
            _M_22挡板降 = False
            _M_1滚轮正转 = False
            _M_1滚轮反转 = False
            _M_2滚轮正转 = False
            _M_2滚轮反转 = False

            _M_2滚轮反转 = value
        End Set
    End Property

    Public Property 手动自动 As Integer
        Get
            Return _手动自动
        End Get
        Set(value As Integer)
            _手动自动 = value
        End Set
    End Property

    Public Property ControlMode As Boolean
        Get
            Return _ControlMode
        End Get
        Set(value As Boolean)
            _ControlMode = value
            If value Then
                lblControlMode.Text = "上位机控制"
            Else
                lblControlMode.Text = "手动控制"
            End If

        End Set
    End Property

    Public Property CarStop As Boolean
        Get
            Return _CarStop
        End Get
        Set(value As Boolean)
            _CarStop = value
            If value Then
                lanStop.Visible = True
                Me.Refresh()
            Else
                lanStop.Visible = False
                Me.Refresh()
            End If
        End Set
    End Property

    Private Sub _StationNo_Click(sender As Object, e As EventArgs) Handles btnUp.Click, btnDn.Click

        btnUp.Selected = Not btnUp.Selected
        btnDn.Selected = Not btnDn.Selected
        If btnUp.Selected Then
            _StationNo = CInt(btnUp.Tag)
        Else
            _StationNo = CInt(btnDn.Tag)
        End If
    End Sub

    Private Sub ucRGV_Load(sender As Object, e As EventArgs) Handles Me.Load
        If Not HslCommunication.Authorization.SetAuthorizationCode("e3e27344-1a9f-4d8b-b4fc-da5cae4b99bf") Then

        End If
        If Not HslControls.Authorization.SetAuthorizationCode("ce5ade06-6f14-4b0d-b9c2-0d625664dc3f") Then

        End If
    End Sub
End Class
